<template>
	<view class="main">
		<view class="navi-bar">
			<view class="navi-back" @click="goBack">
				<
			</view>
			<view class="navi-title">
				{{AuthorDetailsList[0].author.user_name}}
			</view>
		</view>
		<u-gap height="100" bgColor="#fff"></u-gap>
		<view class="aut-info">
			<view class="aut-ava">
				<image :src="AuthorDetailsList[0].author.web_url" mode=""></image>
			</view>
			<view class="aut-name">
				{{AuthorDetailsList[0].author.user_name}}
			</view>
			<view class="aut-sum">
				{{AuthorDetailsList[0].author.summary}}
			</view>
			<view class="aut-an">
				<view class="btn">
					关注
				</view>
			</view>
			<view class="aut-count" v-show="AuthorDetailsList[0].author.fans_total !== ''">
				{{AuthorDetailsList[0].author.fans_total}}关注
			</view>
			<view class="aut-count" v-show="AuthorDetailsList[0].author.fans_total == ''">
				0 关注
			</view>
		</view>
		<view class="aut-list">
			<view class="aut-item" @click="naviTo(a.content_id, a.category)" v-for="(a, i) in AuthorDetailsList" :key="a.id">
				<view class="aut-intro">
					<view class="aut-title">
						{{a.title}}
					</view>
					<view class="aut-author">
						{{a.author.user_name}}
					</view>
					<view class="aut-text">
						{{a.forward}}
					</view>
					<view class="aut-image">
						<image :src="a.img_url" mode="widthFix"></image>
					</view>
					<view class="aut-btn">
						<view class="aut-zf">
							<image src="../../static/icons/zf.png" mode=""></image>
						</view>
						<view class="aut-like">
							<image src="../../static/icons/xh.png" mode=""></image>
							<text class="like-count">{{a.like_count}}</text>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		http
	} from '../../untils/http.js'
	
	export default {
		data() {
			return {
				AuthorDetailsList: []
			}
		},
		onLoad({
			id
		}) {
			this.getAuthorDetails(id)
		},
		methods: {
			getAuthorDetails(id) {
				console.log(id);
				const url = 'author/works?author_id=' + id + '&page_num=0'
				http(url).then(res => {
					this.AuthorDetailsList = res.data
					console.log(this.AuthorDetailsList);
				})
			},
			naviTo(id, category) {
				if (category == 1) {
					uni.navigateTo({
						url: '../ReadContent/ReadContent?id=' + id
					})
				} else if (category == 8) {
					uni.navigateTo({
						url: '../RadioContent/RadioContent?id=' + id
					})
				} else if (category == 3) {
					uni.navigateTo({
						url: '../QuestionContent/QuestionContent?id=' + id
					})
				} else if (category == 2) {
					uni.navigateTo({
						url: '../SerialContent/SerialContent?id=' + id
					})
				}
			},
			goBack() {
				// 返回上一级并刷新当前页面
				this.$router.go(-1)
			}
		}
	}
</script>

<style lang="scss">
	* {
		box-sizing: border-box;
	}
	
	.main {
		background-color: #f1f1f1;
	}
	
	.navi-bar {
		position: fixed;
		width: 750rpx;
		height: 100rpx;
		line-height: 100rpx;
		z-index: 1000;
		background-color: #fff;
		
		.navi-back {
			margin-left: 15px;
			float: left;
		}
		
		.navi-title {
			margin-right: 28px;
			text-align: center;
		}
	}
	
	.aut-info {
		width: 750rpx;
		background-color: #fff;
		
		.aut-ava {
			margin: auto;
			width: 100rpx;
			height: 100rpx;
			
			image {
				width: 100%;
				height: 100%;
				border-radius: 999px;
			}
		}
		
		.aut-name {
			padding: 10px;
			text-align: center;
			font-size: 14px;
		}
		
		.aut-sum {
			text-align: center;
			font-size: 12px;
			color: #a6a6a6;
		}
		
		.aut-an {
			margin-top: 20px;
			text-align: center;
			font-size: 12px;
			// border: 1px solid #adadad;
			
			.btn {
				padding: 4px 10px;
				display: inline-block;
				border: 1px solid #adadad;
			}
		}
		
		.aut-count {
			padding-bottom: 10px;
			margin-top: 10px;
			// margin-bottom: 10px;
			text-align: center;
			font-size: 12px;
			color: #a6a6a6;
		}
	}
	
	.aut-list {
		margin-top: 5px;
	}
	
	.aut-item {
		padding: 10px;
		margin-bottom: 5px;
		background-color: #fff;
	}
	
	.aut-intro {
			box-sizing: border-box;
			margin-bottom: 5px;
			width: 100%;
		}
		
		.aut-title {
			margin-bottom: 3px;
			padding-top: 10px;
			font-size: 14px;
			font-weight: 700;
		}
		
		.aut-author {
			margin-bottom: 10px;
			font-size: 12px;
			color: #828282;
		}
		
		.aut-text {
			margin-bottom: 5px;
			font-size: 12px;
			color: #828282;
			overflow: hidden;
			text-overflow: ellipsis;
			white-space: nowrap;
		}
		
		.aut-image {
			margin-bottom: 5px;
			width: 100%;
			height: 360rpx;
			overflow: hidden;
			border-radius: 5px;
			
			image {
				width: 100%;
			}
		}
		
		.aut-btn {
			display: flex;
			align-items: center;
			flex-direction: row-reverse;
			height: 80rpx;
			
			.aut-zf {
				// padding-bottom: 10px;
			}
			
			.aut-like {
				display: flex;
				margin-right: 20px;
			}
			
			image {
				width: 50rpx;
				height: 50rpx;
			}
			
			.like-count {
				font-size: 10px;
				line-height: 50rpx;
				color: #828282;
			}
		}
	
</style>
